/**
 * Project Name:imgo-b2b-resource
 * @File: BizResult.java
 * @Package: com.cmdt.imgo.b2b.resource.common
 * Copyright (c) 2019 Neusoft Group Ltd. All Rights Reserved.
 * Neusoft PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.xnyzc.lhy.resource.entity.jpush;

import java.io.Serializable;

/**
 * @ClassName: BizResult
 * @Description: TODO
 * @author majch
 * @date 2019-02-26
 * @since OpenJDK 1.8
 */

public class BizResult implements Serializable {

	/**
	 * @Fields serialVersionUID:
	 */
	private static final long serialVersionUID = -1580620424837593435L;

	private int code;

	private String msg;

	private Object data;

	public BizResult() {
	}

	public BizResult(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public static BizResult success() {
		BizResult result = new BizResult();
		result.setResultCode(ResultCode.SUCCESS);
		return result;
	}

	public static BizResult success(Object data) {
		BizResult result = new BizResult();
		result.setResultCode(ResultCode.SUCCESS);
		result.setData(data);
		return result;
	}

	public static BizResult failure(ResultCode resultCode) {
		BizResult result = new BizResult();
		result.setResultCode(resultCode);
		return result;
	}

	public static BizResult failure(ResultCode resultCode, Object data) {
		BizResult result = new BizResult();
		result.setResultCode(resultCode);
		result.setData(data);
		return result;
	}

	public void setResultCode(ResultCode code) {
		this.code = code.code();
		this.msg = code.message();
	}

	public void setData(Object data) {
		this.data = data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

}
